﻿
var viewModel = function (data) {
    console.log(data);
    var me = this;
    me.form = ko.mapping.fromJS(data.form);
    delete me.form.__ko_mapping__;

    me.signout = function (form) {
        com.showComfirm("comfirm", "Are you sure you want to sign out?", function (b) {
            if (!b) return;

            com.ajax({
                type: "GET",
                url: "/Home/SignOut",
                data: ko.toJSON(me.form),
                success: function (retJson) {
                    console.log(retJson);
                    if (retJson && retJson.status === "success") {
                        location.reload();
                    } else {
                        console.log(retJson);
                    }
                }
            });

        });
    };

    me.init = function () {
        if (top != window) {
            alert("top is not a window!");
            top.window.location = window.location;
        }
    };

    this.init();
}
